package com.android.lovely.manager

import android.content.Context
import java.util.Locale

/**
 *
 * @author why
 * @date 2025/3/6 18:57
 */
object LanguageManager {
    fun changeAppLanguage(context: Context, locale: String) {
        val metrics = context.resources.displayMetrics
        val configuration = context.resources.configuration
        val code = locale.split("-")
        val language = code[0]
        var localeR = Locale(language)
        if (code.size > 1) {
            val country = code[1]
            localeR = Locale(language, country)
        }
        configuration.setLocale(localeR)
        context.resources.updateConfiguration(configuration, metrics)
    }
}